package cn.smvc.wechat.servlet;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class WeChatIoServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7607273519573085268L;

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		//设置结构数据格式和编码方式
		req.setCharacterEncoding("UTF-8");
		resp.setCharacterEncoding("UTF-8");
		resp.setContentType("text/html;charset=utf-8");

		//读取微信客户端post发送过来的数据
		InputStream is = req.getInputStream();
		InputStreamReader isr = new InputStreamReader(is, "UTF-8");
		BufferedReader br = new BufferedReader(isr);
		
		String str = "";
		StringBuffer sb = new StringBuffer();
		
		//按行读取内容
		while(null != (str = br.readLine())) {
			sb.append(str);
		}
		String content = sb.toString();
		
		
	}

}
